const public = require("../service/public");

// 获取中国各省
const getprovince = async (ctx) => {
    let res = await public.Getprovince(ctx.query)
    if (res.length > 0) {
        return ctx.body = {
            code: 200,
            message: "获取成功",
            data: res,
        }
    } else {
        return ctx.body = {
            code: 400,
            message: "暂无数据,请稍后再试或联系管理员刘浩QQ499735432,电话15545508600",
        }
    }
}

// 获取中国省份下的市
const getcity = async (ctx) => {
    let res = await public.Getcity(ctx.query)
    if (res.length > 0) {
        return ctx.body = {
            code: 200,
            message: "获取成功",
            data: res,
        }
    } else {
        return ctx.body = {
            code: 400,
            message: "暂无数据,请稍后再试或联系管理员刘浩QQ499735432,电话15545508600",
        }
    }
}

// 获取省份下的市的县
const getcounty = async (ctx) => {
    let res = await public.Getcounty(ctx.query)
    if (res.length > 0) {
        return ctx.body = {
            code: 200,
            message: "获取成功",
            data: res,
        }
    } else {
        return ctx.body = {
            code: 400,
            message: "暂无数据,请稍后再试或联系管理员刘浩QQ499735432,电话15545508600",
        }
    }
}

module.exports = {
    getprovince,//获取中国各省
    getcity,//获取中国省份下的市
    getcounty,//获取省份下的市的县
}